--- /dev/null
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import sys
+
+profile = sys.argv[1]
+
+sys.stdout.write("/* This file is auto-generated. Do not edit. */\n")
+sys.stdout.write("#pragma once\n")
+sys.stdout.write("\n")
+sys.stdout.write(f"#define PROFILE \"{profile}\"\n")
+
+short_sha = os.environ.get('CI_COMMIT_SHORT_SHA')
+if short_sha is not None:
+ sys.stdout.write(f"#define VCS_TAG \"{short_sha}\"\n")
+else:
+ cmd = ["git", "rev-parse", "--short", "HEAD"]
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p:
+ short_sha = p.stdout.read().decode('utf-8').rstrip("\n")
+ sys.stdout.write(f"#define VCS_TAG \"{short_sha}\"\n")
-demo_conf = configuration_data()
-demo_conf.set_quoted('PROFILE', get_option('profile'))
-demo_conf.set_quoted('VCS_TAG', '@VCS_TAG@')
+gen_demo_header = find_program('../build-aux/meson/gen-demo-header.py')
+demo_profile = get_option('profile')
demo_conf_h = declare_dependency(
- sources: vcs_tag(
- command: [ 'git', 'rev-parse', '--short', 'HEAD' ],
- fallback: get_option('profile') != 'default' ? 'devel' : '',
- input: configure_file(
- output: 'demo_conf.h.in',
- configuration: demo_conf
- ),
- output: 'demo_conf.h'
- )
+ sources: custom_target('demo-header',
+ command: [gen_demo_header, demo_profile],
+ capture: true,
+ output: 'demo_conf.h',
+ build_by_default: true,
+ build_always_stale: true,
+ )
)
subdir('constraint-editor')